<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:panelGrid xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:sijyp="http://java.sun.com/jsf/composite/sijyp"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions" id="formDocumentos"
	style="width:100%">


	<br />
	<h:panelGrid id="formDoc" style="width:100%">
		
		<script type="javascript">addTextAreaCounterByClass();</script>
		<h:panelGroup id="innerForm">
			<h:panelGrid columns="4" width="100%"
				columnClasses="tenenciaFirstColumn, , , ">
				<ui:include src="/general/topBienesFormsFields.xhtml">

					<ui:param name="disabledFechaRegistro"
						value="#{bienDocumentoManager.consultaDocumento}" />
					<ui:param name="etapaGestionValue"
						value="#{bienManager.bien.tpEtapaGestion.nombre}" />
					<ui:param name="requiredEtapaGestion" value="false" />
					<ui:param name="disabledEtapaGestion" value="true" />
					<ui:param name="prepId" value="documentos" />
					<ui:param name="hideColumn" value="true" />
				</ui:include>
			</h:panelGrid>
			<hr width="100%" />
			<br />

			<sijyp:fileUploadSijyp
				tiposDocumentos="#{bienDocumentoManager.consultaDocumento ? applicationBean.allTipoDocumentos : applicationBean.tipoDocumentoBienDocumentos}"
				isReading="#{bienDocumentoManager.consultaDocumento}"
				bean="#{bienDocumentoManager}" 
				required="true"
				labelUpload="${msg['bienes.situacion.relacionJuridica.anexo']}"/>

			<h:panelGroup style="text-align:center;" layout="block">

				<h:commandButton value="${msg['boton.adicionar']}"
					action="#{bienDocumentoManager.guardarDocumento}"
					rendered="#{!bienDocumentoManager.edicionDocumento and !bienDocumentoManager.consultaDocumento}">
					<f:ajax execute="@this formDoc"	render="formDoc :sijypMessages dataT" />
				</h:commandButton>

				<a4j:commandButton value="${msg['boton.modificar']}"
					action="#{bienDocumentoManager.modificarDocumento}"
					rendered="#{bienDocumentoManager.edicionDocumento and !bienDocumentoManager.consultaDocumento}"
					render="formTabs:formDoc :sijypMessages dataT"
					execute="@this formDoc" />
				<h:commandButton value="${msg['boton.cancelar']}"
					rendered="#{!bienManager.reading }">
					<f:ajax execute="@this"
						listener="#{bienDocumentoManager.cancelarAccion}"
						render="formTabs:formDoc :sijypMessages dataT" />
				</h:commandButton>
			</h:panelGroup>

		</h:panelGroup>
		<br />

		<a4j:outputPanel ajaxRendered="true" id="dataT">
			<rich:dataTable id="richTable2" var="record_" 
				value="#{bienDocumentoManager.bienDocumentoDataModel}" rows="10"
				noDataLabel="${msg['general.registrosNoEncontrados']}"
				style="margin:0 auto;">

				<ui:include src="/resources/sijyp/jpaColumn.xhtml">
					<ui:param name="bean" value="#{bienDocumentoManager}" />
					<ui:param name="propertyTitle"
						value="bienes.resultadoConsultaBienes.tablaBienes.idBien" />
					<ui:param name="explicitProperty" value="#{record_.bien.idBien}" />
					<ui:param name="propertyFilter" value="bien.idBien" />
					<ui:param name="id" value="columnaOculta" />
					<ui:param name="componentRender" value="richTable2" />
					<ui:param name="hideColumn" value="true" />
				</ui:include>

				<ui:include src="/resources/sijyp/jpaColumn.xhtml">
					<ui:param name="bean" value="#{bienDocumentoManager}" />
					<ui:param name="propertyTitle"
						value="bienes.documentos.descripcion" />
					<ui:param name="explicitProperty" value="#{record_.descripcion}" />
					<ui:param name="propertyFilter" value="descripcion" />
					<ui:param name="componentRender" value="richTable2" />
				</ui:include>
				<ui:include src="/resources/sijyp/jpaColumn.xhtml">
					<ui:param name="bean" value="#{bienDocumentoManager}" />
					<ui:param name="propertyTitle"
						value="bienes.documentos.tipoDocumento" />
					<ui:param name="explicitProperty"
						value="#{record_.tpDocumentoBean.nombre}" />
					<ui:param name="propertyFilter" value="tpDocumentoBean.nombre" />
					<ui:param name="componentRender" value="richTable2" />
				</ui:include>
				<ui:include src="/resources/sijyp/jpaColumn.xhtml">
					<ui:param name="bean" value="#{bienDocumentoManager}" />
					<ui:param name="propertyTitle" value="bienes.documentos.archivo" />
					<ui:param name="explicitProperty" value="#{record_.nombre}" />
					<ui:param name="propertyFilter" value="nombre" />
					<ui:param name="componentRender" value="richTable2" />
					<ui:param name="record" value="#{record_}" />
					<ui:param name="link" value="true" />
				</ui:include>
				<ui:include src="/resources/sijyp/jpaColumn.xhtml">
					<ui:param name="bean" value="#{bienDocumentoManager}" />
					<ui:param name="propertyTitle" value="bienes.documentos.soporte" />
					<ui:param name="explicitProperty" value="#{record_.tab}" />
					<ui:param name="propertyFilter" value="nombre" />
					<ui:param name="componentRender" value="richTable2" />
					<ui:param name="record" value="#{record_}" />
				</ui:include>
				<rich:column>
					<f:facet name="header">
						<sijyp:sortTable title="${msg['bienes.documentos.accion']}"></sijyp:sortTable>
					</f:facet>
					<h:panelGrid columns="3"
						columnClasses="icon_space,icon_space,icon_space">

						<a4j:commandLink value="" execute="@this"
							render=":formTabs:formDoc :sijypMessages"
							action="#{bienDocumentoManager.editarDocumento()}"
							disabled="#{record_.tab != null}"
							rendered="#{!bienDocumentoManager.consultaDocumento and !bienManager.disableSubtabsEditAction}">
							<h:graphicImage
								value="#{record_.tab == null ? '/resources/images/icons/ico_pencil.png' : '/resources/images/icons/ico_pencil_gray.png'}"
								title="${msg['boton.editar']}" />
							<f:setPropertyActionListener
								target="#{bienDocumentoManager.idDocumentoTemporal}"
								value="#{record_.idDocument}" />
						</a4j:commandLink>

						<h:graphicImage
							value="/resources/images/icons/ico_pencil_gray.png"
							title="${msg['boton.editar']}"
							rendered="#{bienManager.disableSubtabsEditAction}" />

						<a4j:commandLink value="" execute="@this"
							render=":formTabs:formDoc :sijypMessages"
							action="#{bienDocumentoManager.consultarDocumento()}">
							<h:graphicImage value="/resources/images/icons/ico_details.png"
								title="${msg['boton.consultar']}" />
							<f:setPropertyActionListener
								target="#{bienDocumentoManager.idDocumentoTemporal}"
								value="#{record_.idDocument}" />
						</a4j:commandLink>

						<a4j:commandLink value="" execute="@this"
							render=":formTabs:formDoc"
							oncomplete="#{rich:component('confirmDeleteDocumento')}.show()"
							rendered="#{!bienDocumentoManager.consultaDocumento and !bienManager.disableSubtabsDeleteAction}"
							disabled="#{record_.tab != null}">
							<h:graphicImage
								value="#{record_.tab == null ? '/resources/images/icons/ico_delete.png' : '/resources/images/icons/ico_delete_disabled.png'}"
								title="${msg['boton.eliminar']}" />
							<f:setPropertyActionListener
								target="#{bienDocumentoManager.idDocumentoTemporal}"
								value="#{record_.idDocument}" />
						</a4j:commandLink>

						<h:graphicImage
							value="/resources/images/icons/ico_delete_disabled.png"
							title="${msg['boton.eliminar']}"
							rendered="#{bienManager.disableSubtabsDeleteAction}" />

					</h:panelGrid>
				</rich:column>
				<f:facet name="footer">
					<rich:dataScroller maxPages="10" fastStep="5" fastControls="hide" stepControls="show" />
				</f:facet>
			</rich:dataTable>
		</a4j:outputPanel>

		<sijyp:confirmDialog message="${msg['general.confirmaBorrar']}"
			confirmId="confirmDeleteDocumento"
			renderComponents=":sijypMessages confirmDeleteDocumento :formTabs:formDoc"
			acceptAction="#{bienDocumentoManager.eliminarDocumento}" />

	</h:panelGrid>
	<br />

</h:panelGrid>